package cn.edu.cqupt.cxcy.timerTask;

import java.util.Calendar;
import java.util.TimerTask;

import javax.servlet.ServletContext;

public class MyTask extends TimerTask {

	 /** 这个代表3点钟的时候执行任务 */  
    private static final int C_SCHEDULE_HOUR = 3;  
    private static boolean isRunning = false;  
    @SuppressWarnings("unused")
	private ServletContext context = null;  
    public MyTask() {  
        super();  
    }  
    public MyTask(ServletContext context) {  
        this.context = context;  
    }  
  
    public void run() {  
        Calendar cal = Calendar.getInstance();  
        if (!isRunning) {  
            if (C_SCHEDULE_HOUR == cal.get(Calendar.HOUR_OF_DAY)) {  
                isRunning = true;  
//                context.log("开始执行指定任务");  
  
                /** 
                 * 此处写执行任务代码 
                 */  
  
                isRunning = false;  
//                context.log("指定任务执行结束");  
            }  
        } else {  
//            context.log("上一次任务执行还未结束");  
        }  
    }  

}
